package com.csvcn.android.activity;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ListView;

import com.csvcn.android.R;
import com.csvcn.android.adapter.BaseListAdapter;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindString;
import butterknife.BindView;
import butterknife.ButterKnife;

public class MainActivity extends Activity {
    @BindString(R.string.main_title)
    String mTtitle;

    @BindView(R.id.base_list_id)
    ListView mListView;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        ButterKnife.bind(this);
        initView();
        setListener();
    }

    private void initView() {
        setTitle(mTtitle);

        List<String> list = new ArrayList<String>();
        list.add("butterknife");
        list.add("retrofit");
        list.add("Picasso");
        list.add("greenDAO");
        mListView.setAdapter(new BaseListAdapter(this, list));
    }

    private void setListener() {
        mListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {

            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                if (position == 2) {
                    startActivity(new Intent(MainActivity.this, PicassoActivity.class));
                }
            }
        });
    }
}
